package com.hx.dao;

import com.hx.pojo.Emp;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class EmpDao {
    private static Map<Integer, Emp> emps=null;
    static {
        emps=new HashMap<Integer, Emp>();
        emps.put(1001,new Emp(1001, "AA", "AA@qqq.com", 1));
        emps.put(1002,new Emp(1002, "BB", "BB@qqq.com", 0));
        emps.put(1003,new Emp(1003, "CC", "CC@qqq.com", 1));
        emps.put(1004,new Emp(1004, "DD", "DD@qqq.com", 0));
        emps.put(1005,new Emp(1005, "EE", "EE@qqq.com", 1));
    }
    private static Integer initId = 1006;

    public void save(Emp emp){
        if (emp.getId()==null){
            emp.setId(initId++);
        }
        emps.put(emp.getId(),emp);
    }
    public Collection<Emp> getAll(){
        return emps.values();
    }
    public Emp get(Integer id){
        return emps.get(id);
    }
    public void delete(Integer id){
        emps.remove(id);
    }
}
